﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NN
{
    public partial class OutputsDialog : Form
    {
        MainWindow theMainWindow;

        public OutputsDialog()
        {
            InitializeComponent();
        }

        private void OKButton_Click(object sender, EventArgs e)
        {
            this.Hide();
        }
        public void setMainWindow(MainWindow win)
        {
            theMainWindow = win;
        }

        public void setInputs(DataGridView theGrid)
        {
            this.dataGridView1.Columns.Clear();
            int colCount;           

            colCount = theMainWindow.theOutputDataList.Count;

            for (int a = 0; a < colCount; a++)
            {                
                DataGridViewColumn tempColumn = new DataGridViewColumn();
                tempColumn.HeaderText = theMainWindow.theOutputList.ElementAt(a);
                tempColumn.Name = theMainWindow.theOutputList.ElementAt(a);
                
                tempColumn.Width = 80;
                tempColumn.CellTemplate = theGrid.Columns[0].CellTemplate;
                this.dataGridView1.Columns.Add(tempColumn);

                if (this.dataGridView1.Rows.Count < theMainWindow.theOutputs.ElementAt(a).PointCount())
                {
                    this.dataGridView1.Rows.Add(theMainWindow.theOutputDataList.ElementAt(a).Count + 1);
                }
                for (int r = 0; r < theMainWindow.theOutputDataList.ElementAt(a).Count; r++)
                {
                    this.dataGridView1.CurrentCell = dataGridView1[a, r];
                    this.dataGridView1.CurrentCell.ReadOnly = false;
                    this.dataGridView1.CurrentCell.Value = theMainWindow.theOutputDataList.ElementAt(a).ElementAt(r);
                    this.dataGridView1.UpdateCellValue(a, r);
                    this.dataGridView1.CurrentCell.ReadOnly = true;
                }

            }

            colCount = this.dataGridView1.Rows.Count;

        }


    }
}
